package
{
	import fl.data.DataProvider;
	import fl.events.ListEvent;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.system.ApplicationDomain;
	import flash.system.LoaderContext;
	import ywh.ui.PhotoTile;
	
	/**
	 * ...
	 * @author 杨伟华
	 */
	public class test_photoTile extends Sprite
	{
		var photoTile:PhotoTile;
		
		public function test_photoTile()
		{
			this.addEventListener(Event.ADDED_TO_STAGE, handleThisAddedToStage);
		}
		
		private function handleThisAddedToStage(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, handleThisAddedToStage);
			var loader:Loader = new Loader();
			var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
			loader.contentLoaderInfo.addEventListener(Event.INIT, init);
			loader.load(new URLRequest("com_slider.swf"), context);
		}
		
		private function init(e:Event):void
		{
			photoTile = new PhotoTile();
			photoTile.setSize(400, 120);
			photoTile.move(100, 100);
			photoTile.columnWidth = 170;
			//photoTile.rowHeight = 100;
			//photoTile.rowCount = 1;
			
			var data:Array = [{source: "../datas/0101/pics/cn/01.png"}, {source: "../datas/0101/pics/cn/02.png"}, {source: "../datas/0101/pics/cn/03.png"}, {source: "http://www.helpexamples.com/flash/images/image2.jpg"}, {source: "http://www.helpexamples.com/flash/images/image3.jpg"}, {source: "http://www.helpexamples.com/flash/images/image1.jpg"}, {source: "http://www.helpexamples.com/flash/images/image2.jpg"}, {source: "http://www.helpexamples.com/flash/images/image3.jpg"}];
			photoTile.dataProvider = new DataProvider(data);
			photoTile.addEventListener(ListEvent.ITEM_CLICK, handlePhotoTileItemClick);
			addChild(photoTile);
		}
		
		private function handlePhotoTileItemClick(e:ListEvent):void
		{
			trace(e.index);
		}
	
	}
}